home *** CD-ROM | disk | FTP | other *** search
/ Mac Format 1997 January / macformat46.iso / File Maker Pro 3.0 Tutorial / File Maker Pro 3.0 / Templates / FileMaker And Apple Events / Sample Applications / Deleting Duplicates / Delete Duplicate Records next >
Text File  |  1996-06-05  |  939b  |  24 lines

  1. set dupFile to "Duplicate Records Database" -- stores the name of the database
  2. set dupCheck to "Unique ID" -- stores the name of the duplicate checking field
  3.  
  4. copy "" to lastRecord --sets up the variable lastRecord
  5. copy 0 to numDeleted --sets up the variable numDeleted
  6.  
  7. tell application "FileMaker Pro" --activates FileMaker Pro
  8.     activate
  9.     show every record of database dupFile
  10.     sort layout 1 by field dupCheck
  11.     copy (count record of database dupFile) to recordCount --counts records
  12.     repeat with i from recordCount to 1 by -1
  13.         copy cell dupCheck of record i to thisRecord --copies record
  14.         if thisRecord = lastRecord then --compares record 
  15.             delete record i --if duplicate, deletes record
  16.             copy 1 + numDeleted to numDeleted
  17.         else
  18.             copy thisRecord to lastRecord
  19.         end if
  20.     end repeat
  21.     display dialog (numDeleted as string) & ¬
  22.         " records were deleted" buttons {"OK"} default button 1
  23.     --displays number of records deleted
  24. end tell